package common;

import storage.beans.SimulationBean;

public class EarthSimSettings {
  private static EarthSimSettings _instance = new EarthSimSettings();
  private int precision = -1;
  private int samplingRate = 100;
  private int temporalAccuracy = 100;
  private int radius;
  private int tilt;
  private float eccentricity;
  private int gridSpacing = Constants.DEFAULT_GRID_SPACING; //in degrees 
  private int timeStep = Constants.DEFAULT_SIM_TIME_STEP; //in minutes
  private long startDateTime;
  private long endDateTime;
  private boolean showingMinTemp = false;
  private boolean showingMaxTemp = false;
  private boolean showingMeanTempRegion = false;
  private boolean showingMeanTempTime = false;
  private boolean showingCellValues = false;
  private boolean animation = false;
  
  private EarthSimSettings() {
  }
  
  public static EarthSimSettings getInstance() {
    return _instance;
  }
  
  public Object clone() throws CloneNotSupportedException {
    throw new CloneNotSupportedException(); 
  }
  
  public int getPrecision() {
    return precision;
  }

  public void setPrecision(int precision) {
    this.precision = precision;
  }

  public int getSamplingRate() {
    return samplingRate;
  }

  public void setSamplingRate(int samplingRate) {
    this.samplingRate = samplingRate;
  }

  public int getTemporalAccuracy() {
    return temporalAccuracy;
  }

  public void setTemporalAccuracy(int temporalAccuracy) {
    this.temporalAccuracy = temporalAccuracy;
  }
    
  public int getRadius() {
    return radius;
  }
  
  /**
   * Radius of the earth in pixels (half the image size)
   * @param radius
   */
  public void setRadius(int radius) {
    this.radius = radius;
  }
  
  public float getEccentricity() {
    return eccentricity;
  }

  public void setEccentricity(float eccentricity) {
    this.eccentricity = eccentricity;
  }

  public long getEndDateTime() {
    return endDateTime;
  }

  public void setEndDateTime(long endDateTime) {
    this.endDateTime = endDateTime;
  }

  public int getGridSpacing() {
    return gridSpacing;
  }

  public void setGridSpacing(int gridSpacing) {
    this.gridSpacing = gridSpacing;
  }

  public long getStartDateTime() {
    return startDateTime;
  }

  public void setStartDateTime(long startDateTime) {
    this.startDateTime = startDateTime;
  }

  public int getTilt() {
    return tilt;
  }

  public void setTilt(int tilt) {
    this.tilt = tilt;
  }

  public int getTimeStep() {
    return timeStep;
  }

  public void setTimeStep(int timeStep) {
    this.timeStep = timeStep;
  }
  
  public boolean isShowingCellValues() {
    return showingCellValues;
  }

  public void setShowingCellValues(boolean showingCellValues) {
    this.showingCellValues = showingCellValues;
  }

  public boolean isShowingMaxTemp() {
    return showingMaxTemp;
  }

  public void setShowingMaxTemp(boolean showingMaxTemp) {
    this.showingMaxTemp = showingMaxTemp;
  }

  public boolean isShowingMeanTempRegion() {
    return showingMeanTempRegion;
  }

  public void setShowingMeanTempRegion(boolean showingMeanTempRegion) {
    this.showingMeanTempRegion = showingMeanTempRegion;
  }

  public boolean isShowingMeanTempTime() {
    return showingMeanTempTime;
  }

  public void setShowingMeanTempTime(boolean showingMeanTempTime) {
    this.showingMeanTempTime = showingMeanTempTime;
  }

  public boolean isShowingMinTemp() {
    return showingMinTemp;
  }

  public void setShowingMinTemp(boolean showingMinTemp) {
    this.showingMinTemp = showingMinTemp;
  }
  
  public boolean isAnimation() {
    return animation;
  }

  public void setAnimation(boolean animation) {
    this.animation = animation;
  }

  public SimulationBean getSimulationBean() {
    SimulationBean bean = new SimulationBean();
    bean.setEccentricity(eccentricity);
    bean.setEndDateTime(endDateTime);
    bean.setGridSpacing(gridSpacing);
    bean.setStartDateTime(startDateTime);
    bean.setTilt(tilt);
    bean.setTimeStep(timeStep);
    bean.setSamplingRate(samplingRate);
    bean.setTemporalAccuracy(temporalAccuracy);
    bean.setPrecision(precision);
    bean.setRadius(radius);
    return bean;
  }
  
  public String toString() {
    String s = 
      "\n----Simulation Settings----"+
      "\nGrid Spacing: "+gridSpacing +
      "\nTime Step: "+timeStep+
      "\nEccentricity: "+eccentricity +
      "\nTilt: "+ tilt +
      "\nSampling Rate: "+samplingRate +
      "\nTemporal Acc: "+temporalAccuracy + 
      "\nPrecision: "+precision + 
      "\nRadius: "+radius
    ;
    return s;      
  }
}
